<template>
  <HerinContainer
    class="MainCoal-box"
    :delay="1"
    direction="Right"
    :title="titles + '运行监测'"
  >
    <!-- tab按钮 -->
    <div slot="tab" class="MainCoal-box-tab">
      <div
        v-for="(item, i) in titletab"
        :key="i"
        :class="['btn', isbtn === item ? 'isbtn' : '']"
        @click="clickTitleTab(item)"
      >
        {{ item }}
      </div>
    </div>
    <!-- 内容区 -->
    <div slot="content" class="MainCoal-box-content">
      <TopVue></TopVue>
      <CenterVue></CenterVue>
      <BottomVue :title="isbtn"></BottomVue>
    </div>
  </HerinContainer>
</template>

<script>
import HerinContainer from '@/components/HerinContainer';
import TopVue from './Top.vue';
import CenterVue from './Center.vue';
import BottomVue from './Bottom.vue';
import { pumpMapList } from '../common/titles';
export default {
  components: {
    HerinContainer,
    TopVue,
    CenterVue,
    BottomVue
  },
  data() {
    return {
      pumpMapList: [],
      titletab: ['前电机', '后电机'],
      isbtn: '前电机'
    };
  },
  computed: {
    titles() {
      let title = '';
      const id = this.$route.params.id;
      if (this.pumpMapList && this.pumpMapList.length > 0) {
        title = this.pumpMapList.find((item) => id === item.id).value;
      }
      return title;
    }
  },
  mounted() {
    this.pumpMapList = pumpMapList;
  },
  methods: {
    clickTitleTab(item) {
      this.isbtn = item;
    }
  }
};
</script>

<style lang='scss' scoped>
.MainCoal-box {
  &-tab {
    display: flex;
    .btn {
      @include btn;
    }
    .isbtn {
      background-color: rgba(0, 228, 255, 0.2);
      color: $cyan;
    }
  }
}
</style>
